package com.kedacom.ctsp.authz.oauth2.util;

import com.kedacom.ctsp.authz.oauth2.vo.AuthorizationCodeVO;
import com.kedacom.ctsp.authz.oauth2.vo.ImplicitAccessTokenVO;

/**
 * redirect 跳转util类
 *
 * @author xuwei
 * @create 2018-05-13 19:00
 **/
public class RedirectUrlUtil {

    public static String redirect(AuthorizationCodeVO model) {
        StringBuffer fullUri = new StringBuffer();
        fullUri.append(model.getRedirectUri())
                .append("?code=").append(model.getCode())
                .append("&state=").append(model.getState())
                .append("&return_uri=").append(model.getReturnUri());
        return fullUri.toString();
    }

    public static String redirect(ImplicitAccessTokenVO model) {
        StringBuffer fullUri = new StringBuffer();
        fullUri.append(model.getRedirectUri())
                .append("?accessToken=").append(model.getAccessToken())
                .append("&state=").append(model.getState())
                .append("&return_uri=").append(model.getReturnUri());
        return fullUri.toString();
    }
}
